package com.cx.service.impl;

import com.cx.mapper.GearboxMapper;
import com.cx.pojo.Gearbox;
import com.cx.service.GearboxService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GearboxServiceImpl implements GearboxService {

    @Autowired
    GearboxMapper gearboxMapper;

    @Override
    public int insert(Gearbox gearbox) {
        return gearboxMapper.insert(gearbox);
    }

    @Override
    public int updateByPrimaryKey(Gearbox gearbox) {
        return gearboxMapper.updateByPrimaryKey(gearbox);
    }

    @Override
    public int deleteByPrimaryKey(Integer gId) {
        return gearboxMapper.deleteByPrimaryKey(gId);
    }

    @Override
    public Gearbox selectByPrimaryKey(Integer gId) {
        return gearboxMapper.selectByPrimaryKey(gId);
    }

    //分页
    public PageInfo<Gearbox> selectAllGearbox(Gearbox gearbox) {
        PageHelper.startPage(gearbox.getPageNum(), gearbox.getPageSize());
        List<Gearbox> gearboxes = gearboxMapper.selectAllGearbox(gearbox);
        return new PageInfo<>(gearboxes);
    }
}
